package com.wx.test;

import com.wx.bean.*;
import com.wx.circulardependencies.A;
import com.wx.circulardependencies.B;
import com.wx.factorybean.MyFactoryBean;
import com.wx.factorybean.MyOriginalFactoryBean;
import com.wx.listener.MyApplicationListener;
import com.wx.multicaster.MyApplicationEventMulticaster;
import com.wx.processor.MyBeanDefinitionRegistryPostProcessor;
import com.wx.processor.MyBeanFactoryPostProcessor;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.*;

@Configuration
//@ComponentScan(basePackages = {"com.wx.listener"})
//@Import(value = {TulingImport.class, MyImportSelector.class})  // beaName = "com.wx.bean.TulingImport"
@ImportResource(value = {"classpath:spring-config.xml"})  // 导入 XML 配置文件
public class MainConfig {

	/**
	 * @see TestHelloSpring#testGetBean()
	 */
//	@Bean
//	@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
//	public People people() {
//		return new People("角落处的一抹微光", 18);
//	}

	/**
	 * @see TestHelloSpring#testFactoryBean()
	 */
	@Bean
	public MyFactoryBean myFactoryBean() {
		return new MyFactoryBean();
	}

	@Bean
	public MyOriginalFactoryBean myOriginalFactoryBean() {
		return new MyOriginalFactoryBean();
	}

	/**
	 * @see TestHelloSpring#testCircularDependencies()
	 */
//	@Bean
//	public A a() {
//		return new A();
//	}
//
//	@Bean
//	public B b() {
//		return new B();
//	}

	/*@Bean
	public A a(B b) {
		return new A(b);
	}

	@Bean
	public B b(A a) {
		return new B(a);
	}*/

//	@Bean
//	public MyApplicationListener myApplicationListener() {
//		return new MyApplicationListener();
//	}

//	@Bean
//	public MyBeanFactoryPostProcessor myBeanFactoryPostProcessor() {
//		return new MyBeanFactoryPostProcessor();
//	}
//
//	@Bean
//	public MyBeanDefinitionRegistryPostProcessor myBeanDefinitionRegistryPostProcessor() {
//		return new MyBeanDefinitionRegistryPostProcessor();
//	}

//	@Bean
//	public MyApplicationEventMulticaster applicationEventMulticaster() {
//		return new MyApplicationEventMulticaster();
//	}

	/*@Bean
	public AutowiredClassA autowiredClassA() {
		return new AutowiredClassA();
	}

	@Bean
	@Primary
	public AutowiredClassB autowiredClassB() {
		return new AutowiredClassB();
	}

	@Bean
	public AutowiredClassB autowiredClassB2() {
		return new AutowiredClassB();
	}*/
}
